<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <video width="800" height="400" id="video" poster="/poster.jpg" controls></video>
    <script>
        var video = document.getElementById('video');
        var codec = 'video/mp4; codecs="avc1.42e01e, mp4a.40.2"';
        if(window.MediaSource && MediaSource.isTypeSupported(codec)){
            //alert('ok')

            var ms = new MediaSource();
    
            video.src = URL.createObjectURL(ms);


            ms.addEventListener('sourceopen',()=>{
                
                let buffer = ms.addSourceBuffer(codec);


                loadBlock(1);

                function loadBlock(num=1){
                    fetch('/video/ceshi_dashinit.mp4?block=' + num).then(res=>res.arrayBuffer()).then(arrayBuffer=>{
           
                        buffer.appendBuffer(arrayBuffer);
                    })
                }

            },false)

        }else{
            //alert('fail');
        }
    </script>
</body>
</html>